Floating Point Support

RTX64 provides floating point support by saving all floating-point registers when necessary. There is no extra work required to support floating point.

When an RTSS floating point operation is encountered in the kernel, an EXCEPTION_NPX_NOT_AVAILABLE is thrown and an RTX64 exception handler turns on the FPU (Floating Point Unit).This allows floating point operations to be performed in the currently executing thread. This exception should only occur once while a thread is actively executing. For instance, if the thread contains two floating point operations back-to-back, only the first floating point operation will cause this exception. The FPU will already be enabled for the second. If there is a context switch, and the thread loses control of the processor, the FPU will be switched back off. The next time this thread is allowed to run, and a floating point operation is encountered, an exception will again be generated to enable the FPU.

Moving Threads Using Floating Point

Threads using floating point registers can be moved from one processor to another (see Moving Threads) until the first call using floating point is made, after which they cannot be moved.

Enabling Floating-Point Support in RTSS Programs

To enable floating-point unit (FPU) support within your application no special action is required. However you should include the Microsoft C Runtime libraries to include the floating-point math routines and printf with floating-point support.

If you are using Microsoft Visual Studio RTX64 Application template, follow the procedure to enable the Microsoft C Runtime support as described in Developing Applications with Visual Studio.

NOTE: Depending on the version of Visual Studio you use, floating-point settings can have an impact on API performance. RTX64 uses the /fp:precise compiler flag. Be aware that this may affect certain API determinism. For example, functions such as log or sin will be affected. For more information, see the Microsoft documentation on /fp (Specify floating-point behavior).

Running RTSS Programs Using Floating-Point

You do not need to follow any special procedures to run an RTSS program that uses floating-point. The program can simply issue Floating-Point Unit (FPU) instructions and call floating-point math routines as done by a standard Win32 program.

Related topics: